#pragma once

#include "helper/sqlite/IDB.h"


namespace helper {
namespace sqlite {

class AutoDBDecorator : public IDB {
public:

  explicit AutoDBDecorator(IDB & db);
  ~AutoDBDecorator() override;

//forward helper::resource::Reopenable 
  std::error_code open() override;
  std::error_code close() override ;
  bool isOpened() const override ;

protected:
  std::error_code _open() override ;
  std::error_code _close() override;

//forward helper::resource::IResource
public:
  bool exists() const override;
  std::error_code destroy() override;

public:
  //IDB forward the request to _db
  std::optional<Statement> createStatement(const std::string & sql, std::error_code & ec) const override;

  const std::string & url() const override;
  void * raw_handler() const override;

private:
  IDB & _db;
};

}//namespace sqlite
}//namespace helper
